package com.zzg.springboot.service;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Service;

import com.zzg.springboot.entity.EngBaseInfo;

@Service
public class EngBaseInfoService {
	
	 @Autowired
	 private JdbcTemplate jdbcTemplate;
	 
	 public List<EngBaseInfo> getList(){
		 String sql = "select erms_biz_eng_base_info.sid,erms_biz_eng_base_info.eng_id,erms_biz_eng_base_info.eng_no,erms_biz_eng_base_info.proj_sid,erms_biz_eng_base_info.eng_name from erms_biz_eng_base_info where rownum <= 10";
		 return (List<EngBaseInfo>) jdbcTemplate.query(sql, new RowMapper<EngBaseInfo>(){

	            @Override
	            public EngBaseInfo mapRow(ResultSet rs, int rowNum) throws SQLException {
	            	EngBaseInfo object = new EngBaseInfo();
	            	object.setSid(rs.getLong("SID"));
	            	object.setEngId(rs.getString("ENG_ID"));
	            	object.setEngNo(rs.getString("ENG_NO"));
	            	object.setProjSid(rs.getLong("PROJ_SID"));
	            	object.setEngName(rs.getString("ENG_NAME"));
	                return object;
	            }
	        });
	 }

}
